Skip to content

[Agents] Improve MPP payment guides - #32185

Merged
irvinebroque merged 9 commits into
cloudflare:productionfrom
parvahuja:parv/mpp-agents-docs
Aug 5, 2026
Merged

[Agents] Improve MPP payment guides#32185
irvinebroque merged 9 commits into
cloudflare:productionfrom
parvahuja:parv/mpp-agents-docs

Conversation

@parvahuja

@parvahuja parvahuja commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Restructures the Machine Payments Protocol (MPP) documentation around Cloudflare tasks while keeping the protocol overview close to the original page.

  • Updates the overview with payment-method independence, charge, session, and subscription intents, x402 compatibility, and links to the Cloudflare how-to guides.
  • Keeps the existing HTTP content guide under Agentic Payments and links to it wherever mpp-proxy is referenced.
  • Shows how to accept MPP payments from a Worker route or an McpAgent tool.
  • Shows how a Cloudflare Agent pays HTTP services and MCP tools with mppx.
  • Removes Lightning and Bitcoin references and minimizes payment-method-specific prose.

The implementation pages remain how-to content. The examples use imperative steps, Cloudflare components, root-relative internal links, TOML Wrangler configuration, and scoped automatic-payment policies.

Depends on cloudflare/mpp-proxy#30, which restores the proxy's advertised charge-only flow.

Before After
payments/mpp.mdx payments/mpp/index.mdx
No dedicated server guide payments/mpp/accept-payments.mdx
No dedicated buyer guide payments/mpp/pay-from-agents-sdk.mdx

Redirects preserve the existing MPP URLs.

Validation

  • Deployed fresh test Workers from the guides.
  • Confirmed an unpaid Worker route returns 402 Payment Required and WWW-Authenticate: Payment.
  • Completed a nonzero testnet payment from an Agent to the Worker route and received Payment-Receipt.
  • Called free and paid McpAgent tools from an Agent; the paid call completed a nonzero testnet payment and returned an MPP Receipt.
  • Confirmed the fixed mpp-proxy returns 200 from /__mpp/health and a charge challenge from unpaid /__mpp/protected.
  • pnpm run check
  • pnpm run format:core:check
  • pnpm exec tsm bin/validate-redirects.ts
  • RUN_LINK_CHECK=true pnpm run build (8,695 pages; all internal links valid)
  • Rendered the MPP pages locally and checked the affected pages for browser-console errors.

Documentation checklist

  • The change adheres to the documentation style guide.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.
  • Files which have changed name or location have been allocated redirects.

@github-actions github-actions Bot added product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/l labels Jul 20, 2026
@parvahuja
parvahuja force-pushed the parv/mpp-agents-docs branch from 2dc338a to 41a7db0 Compare July 20, 2026 23:05
@parvahuja parvahuja changed the title [Agents] Expand MPP payment documentation [Agents] Improve MPP payment guides Jul 21, 2026
@parvahuja
parvahuja marked this pull request as ready for review July 21, 2026 20:31
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review

⚠️ 4 warnings, 💡 2 suggestions found in commit 373a4eb.

👉 Fix in your agent 👈
Fix the following review findings in PR #32185 (https://github.com/cloudflare/cloudflare-docs/pull/32185).

Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
  or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.

The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.

---

## Code Review

### Warnings (4)

#### CR-0ba19327ef74 · Uses deprecated McpAgent API
- **File:** `src/content/docs/agents/tools/payments/mpp/accept-payments.mdx` line 137
- **Issue:** The MCP tool example extends McpAgent and links to /agents/model-context-protocol/apis/agent-api/. Repository docs for that page and related how-to pages state that McpAgent is deprecated, feature-frozen, and that createMcpHandler is the recommended approach for new stateless MCP servers.
- **Fix:** Rewrite the MCP tool example to use createMcpHandler from agents/mcp with the SDK v2 @modelcontextprotocol/server factory pattern, since the payment flow appears stateless. If mppx/server currently requires McpAgent, add a deprecation note and a migration pointer to createMcpHandler.

#### CR-95854bd6667c · Unrestricted automatic MCP payments
- **File:** `src/content/docs/agents/tools/payments/mpp/pay-from-agents-sdk.mdx` line 132
- **Issue:** The MCP example wraps the raw MCP client with payment methods and calls `premium_search` without an `onPaymentRequired` handler or a server/tool allowlist. Unlike the HTTP example, which restricts automatic payments to `https://api.example.com` via `acceptPaymentPolicy`, this snippet could auto-pay any compatible challenge from the connected MCP server.
- **Fix:** If `McpClient.wrap` supports an allowlist or approval callback, configure it here to mirror the HTTP example's origin restriction. Otherwise, add a note warning readers that automatic MCP payments require the same scoping/approval controls as HTTP payments.

#### CR-56f18f4874e7 · Inaccurate protocol header description
- **File:** `src/content/docs/agents/tools/payments/index.mdx` line 39
- **Issue:** The sentence states MPP "adds the `WWW-Authenticate: Payment` and `Authorization: Payment` headers to HTTP `402` responses.`Authorization: Payment` is sent by the client on the retried request, not by the server in the 402 response.
- **Fix:** Clarify the direction of each header: the server returns `WWW-Authenticate: Payment` on the 402 response, and the client retries with `Authorization: Payment`.

#### CR-1dc0ce419532 · Mismatched LinkCard description
- **File:** `src/content/docs/agents/tools/payments/index.mdx` line 53
- **Issue:** The card title is `HTTP content (x402)`, but its description now reads `Gate APIs, web pages, and files with the mpp-proxy Worker` — the `mpp-proxy` Worker is specific to MPP, not x402.
- **Fix:** Restore the x402-specific description, e.g. `Gate APIs, web pages, and files with a Worker proxy`, or otherwise match the description to the x402 guide.

### Suggestions (1)

#### CR-9c9b5045b6ca · Duplicate card description
- **File:** `src/content/docs/agents/tools/payments/index.mdx` line 58
- **Issue:** The `HTTP content (MPP)` card currently uses the same text as the x402 card (`Gate APIs, web pages, and files with the mpp-proxy Worker`), so the descriptions do not distinguish the two protocol guides.
- **Fix:** Give each card a distinct description, ensuring the x402 card does not mention `mpp-proxy` and the MPP card clearly describes its own approach.

---

## Style Guide Review

### Suggestions (1)

#### SG-c104d40c785b · Bullet list with fewer than three items
- **File:** `src/content/docs/agents/tools/payments/index.mdx` line 34
- **Issue:** The x402 integration list has only two bullets: "Server-side" and "Client-side".
- **Fix:** Consider converting the two-item bullet list into prose.

Code Review

This code review is in beta and may not always be helpful — use your judgment.

Warnings (4)
File Issue
agents/tools/payments/mpp/accept-payments.mdx line 137 Uses deprecated McpAgent API — The MCP tool example extends McpAgent and links to /agents/model-context-protocol/apis/agent-api/. Repository docs for that page and related how-to pages state that McpAgent is deprecated, feature-frozen, and that createMcpHandler is the recommended approach for new stateless MCP servers. Fix: Rewrite the MCP tool example to use createMcpHandler from agents/mcp with the SDK v2 @modelcontextprotocol/server factory pattern, since the payment flow appears stateless. If mppx/server currently requires McpAgent, add a deprecation note and a migration pointer to createMcpHandler.
agents/tools/payments/mpp/pay-from-agents-sdk.mdx line 132 Unrestricted automatic MCP payments — The MCP example wraps the raw MCP client with payment methods and calls premium_search without an onPaymentRequired handler or a server/tool allowlist. Unlike the HTTP example, which restricts automatic payments to https://api.example.com via acceptPaymentPolicy, this snippet could auto-pay any compatible challenge from the connected MCP server. Fix: If McpClient.wrap supports an allowlist or approval callback, configure it here to mirror the HTTP example's origin restriction. Otherwise, add a note warning readers that automatic MCP payments require the same scoping/approval controls as HTTP payments.
agents/tools/payments/index.mdx line 39 Inaccurate protocol header description — The sentence states MPP "adds the WWW-Authenticate: Payment and Authorization: Payment headers to HTTP 402 responses.Authorization: Payment is sent by the client on the retried request, not by the server in the 402 response. Fix: Clarify the direction of each header: the server returns WWW-Authenticate: Payment on the 402 response, and the client retries with Authorization: Payment.
agents/tools/payments/index.mdx line 53 Mismatched LinkCard description — The card title is HTTP content (x402), but its description now reads Gate APIs, web pages, and files with the mpp-proxy Worker — the mpp-proxy Worker is specific to MPP, not x402. Fix: Restore the x402-specific description, e.g. Gate APIs, web pages, and files with a Worker proxy, or otherwise match the description to the x402 guide.
Suggestions (1)
File Issue
agents/tools/payments/index.mdx line 58 Duplicate card description — The HTTP content (MPP) card currently uses the same text as the x402 card (Gate APIs, web pages, and files with the mpp-proxy Worker), so the descriptions do not distinguish the two protocol guides. Fix: Give each card a distinct description, ensuring the x402 card does not mention mpp-proxy and the MPP card clearly describes its own approach.

Conventions

No convention issues found.

Style Guide Review

Suggestions (1)
File Issue
agents/tools/payments/index.mdx line 34 Bullet list with fewer than three items — The x402 integration list has only two bullets: "Server-side" and "Client-side". Fix: Consider converting the two-item bullet list into prose.
Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.
/disable-auto-review Stops automatic reviews from triggering on future pushes to this PR. Codeowners can still run /review or /full-review manually.
/rebase Rebases the PR branch against production. On conflict, attempts to resolve automatically using AI. Stops with an explanation if confidence is not high enough.

@irvinebroque

Copy link
Copy Markdown
Contributor

/bonk please review

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clear, well-structured restructure. The new how-to guides fill meaningful gaps in the MPP docs.

I agree with the three warnings from the bot review (bold link text, unhandled MCP OAuth state, and unvalidated connection lookup) and have two additional minor style notes below.

Please address the bot findings before merging.

Comment thread src/content/docs/agents/tools/payments/mpp/accept-payments.mdx Outdated
Comment thread src/content/docs/agents/tools/payments/mpp/pay-from-agents-sdk.mdx Outdated
Comment thread src/content/docs/agents/tools/payments/mpp/pay-from-agents-sdk.mdx Outdated
Comment thread src/content/docs/agents/tools/payments/index.mdx Outdated
Comment thread src/content/docs/agents/tools/payments/index.mdx
@ask-bonk

ask-bonk Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review submitted successfully at cloudflare/cloudflare-docs/pull/32185.

Summary of findings:

  • Agreed with the bot’s 3 warnings and asked the author to address them before merging:

    1. accept-payments.mdx line 20 — bold link text around mpp-proxy violates the style guide.
    2. pay-from-agents-sdk.mdx line 116 — addMcpServer() can return an OAuth authUrl that must be handled.
    3. pay-from-agents-sdk.mdx line 122 — mcpConnections[id] should be null-checked before dereferencing .client.
  • Added 2 minor style/consistency notes:

    • payments/index.mdx card title “Pay with MPP” doesn’t match the target page title “Pay from the Agents SDK.”
    • Inconsistent capitalization in the payment flow steps on payments/index.mdx (Challenge vs. credential vs. receipt).

github run

@parvahuja
parvahuja force-pushed the parv/mpp-agents-docs branch from 3c237bf to f07cb78 Compare July 22, 2026 18:38
Comment thread src/content/docs/agents/tools/payments/index.mdx Outdated
@parvahuja
parvahuja force-pushed the parv/mpp-agents-docs branch from be285b7 to 0566dd2 Compare July 23, 2026 19:17
@irvinebroque

Copy link
Copy Markdown
Contributor

/bonk rebase branch off production

@irvinebroque
irvinebroque enabled auto-merge (squash) July 26, 2026 18:38
@ask-bonk

ask-bonk Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Rebased successfully — the parv/mpp-agents-docs branch is now cleanly stacked on the latest production (8c3a2ab).

  • Before: 9 PR commits on top of an older production base
  • After: 9 rebased PR commits on top of 8c3a2ab (sync model catalog)

The branch previously contained 11 extra commits that were already in production due to a shallow clone during the first rebase attempt. After fetching the full production history and re-running the rebase, only the 9 actual PR commits were replayed — no conflicts.

github run

@irvinebroque

Copy link
Copy Markdown
Contributor

/rebase

auto-merge was automatically disabled July 27, 2026 23:22

Head branch was pushed to by a user without write access

@parvahuja
parvahuja force-pushed the parv/mpp-agents-docs branch from 0566dd2 to 5360e27 Compare July 27, 2026 23:22
@parvahuja

Copy link
Copy Markdown
Contributor Author

rebased!

@irvinebroque
irvinebroque enabled auto-merge (squash) July 27, 2026 23:34
@parvahuja
parvahuja requested a review from rohinlohe July 29, 2026 00:24
@parvahuja

Copy link
Copy Markdown
Contributor Author

i think still waiting on a 👍

auto-merge was automatically disabled July 29, 2026 17:51

Head branch was pushed to by a user without write access

@parvahuja
parvahuja force-pushed the parv/mpp-agents-docs branch 3 times, most recently from 795d3eb to 65efe6a Compare August 3, 2026 16:00

@rohinlohe rohinlohe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@irvinebroque
irvinebroque enabled auto-merge (squash) August 5, 2026 21:09
auto-merge was automatically disabled August 5, 2026 21:14

Head branch was pushed to by a user without write access

@parvahuja
parvahuja force-pushed the parv/mpp-agents-docs branch from 65efe6a to 373a4eb Compare August 5, 2026 21:14
@irvinebroque
irvinebroque enabled auto-merge (squash) August 5, 2026 23:17
@irvinebroque
irvinebroque merged commit 3f39c22 into cloudflare:production Aug 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants